/**
@file heap_snorch.h
@brief heap implementation by snorch
* done: heap structure; alloc();
*
 */

#ifndef _HEAP_SNORCH_H_
#define _HEAP_SNORCH_H_

#include <windows.h> //for CriticalSection

#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
//#include<list>
//#include <map>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

#include "../../api/heap.h"

using namespace std;

#define VECTOR_SIZE 1
#define soi_const sizeof(int)
typedef pair<void* , int > MYi;
typedef pair<size_t ,  MYi > MYiv1;
typedef vector<MYiv1> MYviv;
typedef MYviv::iterator MYvivIt;

class heap_snorch: public heap876
{
private:
    CRITICAL_SECTION CriticalSection;
    void* AMem; //points on allocated mem
    size_t AMemSize;//allocated memory size

    //todo: manage strucrure
    MYviv Blocks;
    MYviv AlBlocks; //allocated blocks size
    MYvivIt it;


    //

public:
    heap_snorch( size_t total, alloc_flags flag);
    virtual ~heap_snorch();
    virtual void*	alloc( size_t sz, unsigned int tag );
    virtual void	free( void* ptr );
    virtual void	free_all( unsigned int tag );
    virtual size_t get_occupancy() const;
    virtual MYiv1 MYiv(size_t sz, void* ptr);
    virtual MYiv1 MYiv(size_t sz, void* ptr, int tag);

};

#endif//__HEAP_SNORCH_H__
